package com.agent.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.agent.exception.MyException;
import com.agent.exception.StaticExceptionCodes;
import com.agent.mapper.AgentTravelAgencyMapper;
import com.agent.mapper.TravelAgencyMapper;
import com.agent.model.AgentTravelAgency;
import com.agent.service.IAgentTravelAgencySer;

@Service("agentTravelAgencySer")
public class AgentTravelAgencySerImpl implements IAgentTravelAgencySer{

	@Autowired
	AgentTravelAgencyMapper agentTravelAgencyMapper;
	@Autowired
	TravelAgencyMapper travelAgencyMapper;
	
	/*领取公海旅行社*/
	public int addAgentTravelAgency(AgentTravelAgency agentTravelAgency) throws MyException {
		int result = agentTravelAgencyMapper.addAgentTravelAgency(agentTravelAgency);
		if(result<=0){
			throw new MyException(StaticExceptionCodes.AgentTravelAgencyExcepion.addAgentTravelAgencyFail);
		}
		travelAgencyMapper.updateTravelAgencyToken(agentTravelAgency.getTravelAgencyid());
		return result;
	}

}
